Component({
  relations: {
    './grids': {
      type: 'parent'
    }
  },
  options: {
    multipleSlots: true
  },
  properties: {
    index: { //序号
      type: [String, Number],
      value: ''
    },
    url: { //跳转链接
      type: String,
      value: ''
    },
    imgUrl: { //图标路径
      type: String,
      value: ''
    },
    imgSize: { //图片/图标尺寸
      type: [String, Number],
      value: 24
    },
    text: { //文本
      type: String,
      value: ''
    },
    textColor: { //文本颜色
      type: String,
      value: '#333'
    },
    textSize: { //文本字体大小
      type: [String, Number],
      value: 14
    },
    navigateTo: { //跳转方式
      type: String,
      value: ''
    },
    showBorder: { //是否显示边框
      type: [Boolean],
      value: false
    }
  },
  data: {
  },
  methods: {
    clickGrid() {
      let url = this.data.url;
      if (url) {
        switch (this.data.navigateTo) {
          case 'redirectTo':
            wx.redirectTo({
              url: url
            });
            break;
          case 'switchTab':
            wx.switchTab({
              url: url
            });
            break;
          case 'reLaunch':
            wx.reLaunch({
              url: url
            });
            break;
          default:
            wx.navigateTo({
              url: url
            });
        }
      }else{
        this.triggerEvent('click',this.data.index)
      }
    }
  }
})
